﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ajax 分页</title>
<script src="ajax.js"></script>
<script>
window.onload=function ()
{
	var oUl=document.getElementById('ul1');
	var aBtn=document.getElementsByTagName('a');
	var i=0;
	
	for(i=0;i<aBtn.length;i++)
	{
		aBtn[i].index=i;
		aBtn[i].onclick=function ()
		{
			ajax('page'+(this.index+1)+'.txt', function (str){
				var aData=eval(str);
				
				oUl.innerHTML='';
				for(i=0;i<aData.length;i++)
				{
					var oLi=document.createElement('li');
					
					oLi.innerHTML='<strong>'+aData[i].user+'</strong><i>'+aData[i].pass+'</i>';
					
					oUl.appendChild(oLi);
				}
			});
		};
	}
};
</script>
</head>

<body>
<ul id="ul1">
</ul>
<a href="javascript:;">1</a>
<a href="javascript:;">2</a>
<a href="javascript:;">3</a>
</body>
</html>
